using System.Collections.Generic;
using System.Linq;
using AllIsWell.Core.Models;

namespace AllIsWell.Persistance.Ef
{
    public class WhatRepository : IWhatRepository
    {
        private readonly MyDiary _myDiary;

        public WhatRepository(MyDiary myDiary)
        {
            _myDiary = myDiary;
        }

        public IEnumerable<What> GetWhats(int destinyId)
        {
            return _myDiary.Whats.Where(what => what.Destiny.Id == destinyId);
        }

        public What GetWhat(int whatId)
        {
            return _myDiary.Whats.First(what => what.Id == whatId);
        }
    }
}